package com.sise.wangzhan;

import com.alibaba.fastjson.JSON;
import com.netflix.client.http.HttpRequest;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import javax.xml.transform.Templates;
import java.util.HashMap;
import java.util.Map;

/**
 * @Classname PeopleController
 * @Description TODO
 * @Date 2020/4/2 9:11
 * @Created by wangzhan
 */
@RestController
public class PeopleController {

    @RequestMapping(value = "/person/{person_id}",method = RequestMethod.GET)
    public String findId(@PathVariable("person_id") Integer person_id, HttpServletRequest request){
        People people = new People(person_id, "wangzhan", 22);
        people.setMessage(request.getRequestURL().toString());

        Map<String,String> map = new HashMap<String, String>();
        map.put("用户ID",people.getPerson_id().toString());
        map.put("用户名",people.getP_name());
        map.put("年龄",Integer.toString(people.getAge()));
        map.put("请求URL",people.getMessage());


        String s = JSON.toJSONString(map);

        return s;
    }

}
